﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Collections;
using System.Collections.Specialized;
namespace Tracy.CoreLib.Data
{
    public interface IXmlModel
    {
        string XmlNodeName { get; }
        //StringDictionary Data { get; }
        string GetValue(string key);
        void SetValue(string key, string value); 
        void LoadXml(string xml);
        void LoadXml(XmlNode node);
        void Load(string url);
        void Load(XmlReader reader);
        XmlNode ToXmlNode(XmlDocument doc);
        string ToXml(XmlDocument doc);
        string ToXml();
    }

    public interface IKeyedItem
    {
        string Key
        {
            get;
        }
    }

    public interface IXmlModelContainer : IXmlModel
    {
        string XmlChildNodeName { get; }
        IXmlModelItem GenerateChild(XmlNode node);
        IXmlModelCollection Items { get; }
        void AddItem(IXmlModelItem newItem);
        IXmlModelItem AddItem(XmlNode node);
        void RemoveItem(IXmlModelItem oldItem);
    }
    public interface IXmlModelProvider : IXmlModelContainer
    {
        int LargestId { get; }
        void AddItem(IManagedXmlModelItem newItem);
        IManagedXmlModelItem GetItemById(int id);
    }
    public interface IXmlModelItem : IXmlModel, IKeyedItem
    {

    }

    public interface IManagedXmlModelItem : IXmlModelItem
    {
        int Id { get; set; }
    }

    public interface IXmlModelCollection : IList<IXmlModelItem>
    {
        IXmlModelItem this[string key] { get; }
        bool Contains(string key);
    }

    public interface IManagedXmlModelCollection : IXmlModelCollection
    {
        IManagedXmlModelItem GetItemById(int Id);
        bool ContainsId(int id);
        int IndexOf(int id);
        IManagedXmlModelCollection GetCopy();
    }
}
